/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EmentaForm.java
 *
 * Created on 02/08/2011, 11:35:37
 */
package savet.gui.forms;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import org.openswing.swing.mdi.client.InternalFrame;
import savet.entidades.Ementa;
import savet.repositorio.EmentaJpaController;
import savet.repositorio.exceptions.PreexistingEntityException;

/**
 *
 * @author Rafael
 */
public class EmentaForm extends InternalFrame {

    private Ementa ementa;
    private EmentaJpaController controller = new EmentaJpaController();

    /** Creates new form EmentaForm */
    public EmentaForm() {
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch (Exception ex) {
        }
        initComponents();
//
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        editButton1 = new org.openswing.swing.client.EditButton();
        reloadButton1 = new org.openswing.swing.client.ReloadButton();
        genericButton1 = new org.openswing.swing.client.GenericButton();
        saveButton = new org.openswing.swing.client.SaveButton();
        jPanel1 = new javax.swing.JPanel();
        textAreaControlNotaObs = new org.openswing.swing.client.TextAreaControl();
        jLabel5 = new javax.swing.JLabel();
        textAreaControlCapitulacao = new org.openswing.swing.client.TextAreaControl();
        jLabel4 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jComboBoxGrupo = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        textAreaControlDescricao = new org.openswing.swing.client.TextAreaControl();
        jLabel1 = new javax.swing.JLabel();
        formattedTextCodEmenta = new org.openswing.swing.client.FormattedTextControl();
        jComboBoxPenalidade = new javax.swing.JComboBox();
        jComboBoxTipoEmenta = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldGradacao = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Nova Ementa");

        editButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editButton1ActionPerformed(evt);
            }
        });

        reloadButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reloadButton1ActionPerformed(evt);
            }
        });

        genericButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                genericButton1ActionPerformed(evt);
            }
        });

        saveButton.setAttributeName("salvar");
        saveButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(102, 102, 102)), "Ementa", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 14))); // NOI18N

        jLabel5.setText("Nota/Obs:");

        jLabel4.setText("Capitulação");

        jLabel2.setText("Grupo");

        jComboBoxGrupo.setModel(new javax.swing.DefaultComboBoxModel( new String[]{" ","AERONAUTAS","ALTERAÇÃO CONTRATUAL","ARTISTAS E TÉCNICOS EM ESPETÁCULOS DE DIVERSÕES","ATUÁRIOS","AVISO PRÉVIO","BANCÁRIOS","BRASILEIROS E ESTRANGEIROS - PROPORCIONALIDADE","CAGED","CONTRATO INDIVIDUAL DO TRABALHO","CONTRATO POR PRAZO DETERMINADO","CONTRIBUIÇÃO SINDICAL","DA FISCALIZAÇÃO","DESCANSO","EQUIPAGENS DE EMBARCAÇÕES","FERROVIÁRIOS","FGTS","FGTS - CONTRIBUIÇÃO SOCIAL","FÉRIAS","GRATIFICAÇÃO DE NATAL","INSTITUIÇÃO SINDICAL","JORNADA DE TRABALHO","JORNALISTAS PROFISSIONAIS","MORA CONTUMAZ","MÚSICOS","OPERADORES CINEMATOGRÁFICOS","PESSOAS COM DEFICIÊNCIA","PROFESSORES","PROPAGANDISTAS E VENDEDORES DE PRODUTOS FARMACÊUTICOS","PROTEÇÃO AO TRABALHO DO MENOR","PRÁTICAS DISCRIMINAT ÓRIAS","PUBLICITÁRIOS","QUADRO HORÁRIO","QUÍMICOS","RADIALISTA","RAIS","REGISTRO E CTPS","REMUNERAÇÃO","RESCISÃO CONTRATUAL","SALÁRIO MÍNIMO","SEGURO-DESEMPREGO","SERVIÇOS FRIGORÍFICOS","SUSPENSÃO E DA INTERRUPÇÃO","TELEFONIA - TELEGRAFIA - RADIOTELEGRAFIA","TRABALHO AVULSO","TRABALHO DA MULHER","TRABALHO EM MINAS DE SUBSOLO","TRABALHO NAS ATIVIDADES PETROLÍFERAS","TRABALHO NOTURNO","TRABALHO PORTUÁRIO","TRABALHO RURAL","TRABALHO TEMPORÁRIO","VALE-TRANSPORTE","NR-1 DISPOSIÇÕES GERAIS","NR-10 INSTALAÇÕES E SERVIÇOS EM ELETRICIDADE","NR-11 TRANSPORTE, MOVIMENTAÇÃO, ARMAZENAGEM EMANUSEIO DE MATERIAIS","NR-12 MÁQUINAS E EQUIPAMENTOS","NR-13 CALDEIRAS E VASOS SOB PRESSÃO","NR-14 FORNOS","NR-15 ATIVIDADES E OPERAÇÕES INSALUBRES","NR-16 ATIVIDADES E OPERAÇÕES PERIGOSAS","NR-17 ERGONOMIA","NR-18 CONDIÇÕES  E MEIO AMBIENTE DE TRABALHO NA INDÚSTRIA DA CONSTRUÇÃO","NR-19 EXPLOSIVOS","NR-20 LÍQUIDOS COMBUSTÍVEIS E INFLAMÁVEIS","NR-21 TRABALHO A CÉU ABERTO","NR-22 SEGURANÇA E SAÚDE OCUPACIONAL NA MINERAÇÃO","NR-23 PROTEÇÃO CONTRA INCÊNDIOS","NR-24 CONDIÇÕES SANITÁRIAS  E DE CONFORTO NOS LOCAIS DE TRABALHO","NR-25 RESÍDUOS INDUSTRIAIS","NR-26 SINALIZAÇÃO DE SEGURANÇA","NR-29 SEGURANÇA E SAÚDE NO TRABALHO PORTUÁRIO","NR-3 EMBARGO OU INTERDIÇÃO","NR-30 SEGURANÇA E SAÚDE NO TRABALHO AQUAVIÁRIO","NR-31 SST NA AGRICULTURA, PECUÁRIA SILVICULTURA, EXPLORAÇÃO FLORESTAL E AQÜICULTURA","NR-32 SEGURANÇA E SAÚDE NO TRABALHO EM SERVIÇOS DE SAÚDE","NR-33 SEGURANÇA E SAÚDE NOS TRABALHOS EM ESPAÇOS CONFINADOS","NR-4 SERVIÇOS ESPECIALIZADOS EM ENGENHARIA DE SEGURANÇA E EM MEDICINA DO TRABALHO","NR-5 COMISSÃO INTERNA DE PREVENÇÃO DE ACIDENTES - CIPA","NR-6 EQUIPAMENTO DE PROTEÇÃO INDIVIDUAL- EPI","NR-7 PROGRAMA DE CONTROLE MÉDICO DE SAÚDE OCUPACIONAL","NR-8 EDIFICAÇÕES","NR-9 PROGRAMA DE PREVENÇÃO DE RISCOS"}
        ));

        jLabel3.setText("Descrição");

        jLabel1.setText("Código");

        jComboBoxPenalidade.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "penalidade per capita"}));
        jComboBoxPenalidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxPenalidadeActionPerformed(evt);
            }
        });

        jComboBoxTipoEmenta.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " ", "L", "S"}));
        jComboBoxTipoEmenta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxTipoEmentaActionPerformed(evt);
            }
        });

        jLabel6.setText("Penalidade");

        jLabel7.setText("Tipo de Ementa");

        jLabel8.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        jLabel8.setText("L(Legislação)");

        jLabel9.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N
        jLabel9.setText("S(SST)");

        jTextFieldGradacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldGradacaoActionPerformed(evt);
            }
        });

        jLabel10.setText("Gradação:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(textAreaControlNotaObs, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 579, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(textAreaControlCapitulacao, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 579, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(textAreaControlDescricao, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 579, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jComboBoxGrupo, javax.swing.GroupLayout.Alignment.LEADING, 0, 579, Short.MAX_VALUE))
                                .addGap(36, 36, 36)))
                        .addGap(147, 147, 147))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(formattedTextCodEmenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBoxPenalidade, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jComboBoxTipoEmenta, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel9)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addComponent(jLabel7))
                        .addGap(37, 37, 37)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldGradacao, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10)))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(23, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel10))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jComboBoxPenalidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jComboBoxTipoEmenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldGradacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(formattedTextCodEmenta, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(17, 17, 17)
                        .addComponent(jLabel2))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel8)
                            .addGap(13, 13, 13))
                        .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxGrupo, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textAreaControlDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textAreaControlCapitulacao, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textAreaControlNotaObs, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 611, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(genericButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(reloadButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(editButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(saveButton, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(editButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(reloadButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(genericButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        editButton1.setText("Editar");
        genericButton1.setText("Limpar");
        saveButton.setText("Salvar");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        try {

            ementa = new Ementa();
            ementa.setEmenta(formattedTextCodEmenta.getText());
            ementa.setGrupo((String) jComboBoxGrupo.getSelectedItem());
            ementa.setCapitulacao(textAreaControlCapitulacao.getTextArea().getText());
            ementa.setNota(textAreaControlNotaObs.getTextArea().getText());
            ementa.setGradacao(jTextFieldGradacao.getText());
            ementa.setTipo((String) jComboBoxTipoEmenta.getSelectedItem());
            ementa.setDescricao(textAreaControlDescricao.getTextArea().getText());
            ementa.setPerCapita((String) jComboBoxPenalidade.getSelectedItem());
            if (getTitle().equals("Nova Ementa")) {
                controller.create(ementa);
            } else if (getTitle().equals("Editar Ementa")) {
                controller.edit(ementa);
            }
            JOptionPane.showMessageDialog(null, "Ementa salva com sucesso!");
        } catch (PreexistingEntityException ex) {
            JOptionPane.showMessageDialog(null, "Código da ementa já exite!", "Erro", JOptionPane.ERROR_MESSAGE);
            Logger.getLogger(EmentaForm.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
            Logger.getLogger(EmentaForm.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_saveButtonActionPerformed

    private void editButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_editButton1ActionPerformed

    private void reloadButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reloadButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_reloadButton1ActionPerformed

    private void genericButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genericButton1ActionPerformed
        setTitle("Nova Ementa");
        formattedTextCodEmenta.setEnabled(true);
        formattedTextCodEmenta.setText(null);
        jComboBoxGrupo.setSelectedItem(null);
        textAreaControlCapitulacao.getTextArea().setText(null);
        textAreaControlNotaObs.getTextArea().setText(null);
        jTextFieldGradacao.setText(null);
        jComboBoxTipoEmenta.setSelectedItem(null);
        textAreaControlDescricao.getTextArea().setText(null);
        jComboBoxPenalidade.setSelectedItem(null);
    }//GEN-LAST:event_genericButton1ActionPerformed

    private void jComboBoxPenalidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxPenalidadeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxPenalidadeActionPerformed

    private void jComboBoxTipoEmentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxTipoEmentaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxTipoEmentaActionPerformed

    private void jTextFieldGradacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldGradacaoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldGradacaoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new EmentaForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.openswing.swing.client.EditButton editButton1;
    private org.openswing.swing.client.FormattedTextControl formattedTextCodEmenta;
    private org.openswing.swing.client.GenericButton genericButton1;
    private javax.swing.JComboBox jComboBoxGrupo;
    private javax.swing.JComboBox jComboBoxPenalidade;
    private javax.swing.JComboBox jComboBoxTipoEmenta;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextFieldGradacao;
    private org.openswing.swing.client.ReloadButton reloadButton1;
    private org.openswing.swing.client.SaveButton saveButton;
    private org.openswing.swing.client.TextAreaControl textAreaControlCapitulacao;
    private org.openswing.swing.client.TextAreaControl textAreaControlDescricao;
    private org.openswing.swing.client.TextAreaControl textAreaControlNotaObs;
    // End of variables declaration//GEN-END:variables

    public Ementa getEmenta() {
        return ementa;
    }

    public void setEmenta(Ementa ementa) {
        this.ementa = ementa;
        visualizarDados();
    }

    private void visualizarDados() {
        setTitle("Editar Ementa");
        formattedTextCodEmenta.setText(ementa.getEmenta());
        formattedTextCodEmenta.setEnabled(false);
        jComboBoxGrupo.setSelectedItem(ementa.getGrupo());
        textAreaControlCapitulacao.getTextArea().setText(ementa.getCapitulacao());
        textAreaControlNotaObs.getTextArea().setText(ementa.getNota());
        jTextFieldGradacao.setText(ementa.getGradacao());
        jComboBoxTipoEmenta.setSelectedItem(ementa.getTipo());
        textAreaControlDescricao.getTextArea().setText(ementa.getDescricao());
        jComboBoxPenalidade.setSelectedItem(ementa.getPerCapita());

    }
}
